/*
 * @lc app=leetcode.cn id=46 lang=cpp
 *
 * [46] 全排列
 */

// @lc code=start
#include <bits/stdc++.h>
using namespace std;
class Solution {
public:
    vector<vector<int>> ans;

    void dfs(vector<int>& nums, int inx)
    {
        if(inx == nums.size() - 1)
        {
            ans.push_back(nums);
            return;
        }
        for(int i = inx; i < nums.size(); i++)
        {
            swap(nums[i], nums[inx]);
            dfs(nums, inx + 1);
            swap(nums[i], nums[inx]);
        }
    }

    vector<vector<int>> permute(vector<int>& nums) {
        
        dfs(nums, 0);

        return ans;
    }
};
// @lc code=end

